package com.tpfinal.agenda.view.renderers;

abstract class Filter {

	protected String stringFilter;
	protected ContactsTableModel model;

	public Filter(ContactsTableModel model) {
		this.model = model;
	}

	abstract void render(String stringFilter);

	void render() {
		render("");
	}

	protected final void showColumn(int columnIdx, boolean show) {
		if (!show) {
			model.getParent().getColumnModel().getColumn(columnIdx)
					.setMinWidth(0);
			model.getParent().getColumnModel().getColumn(columnIdx)
					.setMaxWidth(0);
			model.getParent().getColumnModel().getColumn(columnIdx).setWidth(0);
		} else {
			model.getParent()
					.getColumnModel()
					.getColumn(columnIdx)
					.setMinWidth(
							model.getParent().getColumnModel().getColumn(0)
									.getMinWidth());
			model.getParent()
					.getColumnModel()
					.getColumn(columnIdx)
					.setMaxWidth(
							model.getParent().getColumnModel().getColumn(0)
									.getMaxWidth());
			model.getParent()
					.getColumnModel()
					.getColumn(columnIdx)
					.setWidth(
							model.getParent().getColumnModel().getColumn(0)
									.getWidth());
		}
	}

}
